package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.BlackListMapper;
import com.tanhua.dubbo.mappers.UserInfoMapper;
import com.tanhua.model.db.UserInfo;
import com.tanhua.model.domain.BlackList;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Autowired
    private BlackListMapper blackListMapper;

    //根据id查询
    @Override
    public IPage<UserInfo> findByUserId(Long userId, Integer page, Integer pageSize) {
        Page<BlackList> page1 = new Page<>(page,pageSize);

        return userInfoMapper.findBlackList(page1,userId);
    }

    //删除用户的的黑名单信息
    @Override
    public void delete(Long userId, Long blackUserId) {
        QueryWrapper<BlackList> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        wrapper.eq("black_user_id",blackUserId);
        blackListMapper.delete(wrapper);
    }
}
